<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use DB;
use App\Models\Squad;
use App\Models\Crouse;
use App\Models\Classroom;
use App\Models\Notice;


class Progress extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'progress';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        //每月1号为班主任生成所带各班级的名单确认待办记录
        //获取所有班级ids
        $mingdan_squads = Squad::all()->toArray();
        for ($j= 0; $j < count($mingdan_squads); $j++) { 
            $mingdan_data[] = [
                'notice_type' =>'6',
                'event' =>'进度确认！('.$mingdan_squads[$j]['name'].'班-'.date('Y').'年'.date('m').'月学习进度确认！)',
                'starttime' =>date('Y-m-d H:i:s'),
                'grace_days'=>'7',
                'endtime' =>date('Y-m-d H:i:s',strtotime('+7 day')),
                'status'=>'1',
                'squad_id'=>$mingdan_squads[$j]['id'],
                'tutor_id'=>$mingdan_squads[$j]['class_teacher']
            ]; 
        }
        
        $mingdan_res = Notice::insert($mingdan_data);
    }
}
